<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="java.util.*,org.skywind.WindSearch.*,org.skywind.WindSearch.interfaces.*,org.skywind.Robot.interfaces.*,org.skywind.Robot.pageRobots.TextTagParser" %>
<%
	Date start = new Date();
	request.getServerName();
%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		<link rel="stylesheet" type="text/css" href="style.css" />
		<script type="text/javascript" src="AccControl.js"></script>
	<head>
		<title>业务主机管理</title>
	</head>

	<body>
		<center>
<div>
			<c:forEach items="${system.hosts}" var="host">
				<div style="width: 240px; border: #999999 0px solid; float: left;margin: 10px">
					<table width="100%"
						style="border: #999999 1px solid; padding: 1px; font-size: 12px"
						cellspacing="1" cellpadding="0">
						<tr>
							<td colspan="2">
								<a
									href="../RemotContrl.jsp?host=${host.name }&width=800&height=600"><img
										width=240 height=180 style="border: 0px; margin: 0px"
										src="../RemoteScreen?img=true&host=${host.name }&robot=0&width=220&height=180">
								</a>
							</td>
						</tr>
						<tr>
							<td align="left" width="30%" style="background-color: #99ccff">
								主机名称
							</td>
							<td align="left" style="background-color: #ddd">
								${host.name}
							</td>
						</tr>
						<tr>
							<td align="left" width="30%" style="background-color: #99ccff">
								主机地址
							</td>
							<td align="left" style="background-color: #ddd">
								${host.address.hostName}:${host.port}
							</td>
						</tr>
						<tr>
							<td align="left" style="background-color: #99ccff">
								对象库
							</td>
							<td align="left" style="background-color: #ddd">
								${host.status}
							</td>
						</tr>
					</table>
					<div id="accordion_panel_${host.name}" class="panel"
						style="width: 100%; padding: 1px">
						<h3 class="deep-top" style="width: 100% px">
							对象池信息
						</h3>
						<div style="width: 100% px">
							<table width="100%">
								<tr>
									<td style="background-color: #99ccdd">
										<b>远程指针</b>
									</td>
									<td style="background-color: #99ccdd">
										<b>对象接口</b>
									</td>
								</tr>
								<%
									OperationHost host = (OperationHost) pageContext
												.getAttribute("host");
										Map<String, Object> map = host.getObjectPool();
										Iterator<String> ite = map.keySet().iterator();
										while (ite.hasNext()) {
											String key = ite.next();
											Object obj = map.get(key);
											pageContext.setAttribute("Key", key);
											//pageContext.setAttribute("Value", obj);
											pageContext.setAttribute("Interfaces", obj.getClass()
													.getInterfaces());
								%>
								<tr>
									<td style="background-color: #ccc">
										${Key }
									</td>
									<td style="background-color: #ccc">
										<c:forEach items="${Interfaces}" var="interf">
									${interf }<br>
										</c:forEach>
									</td>
								</tr>
								<%
									}
								%>
							</table>
						</div>


						<h3 class="deep" style="width: 100% px">
							网络爬虫列表
						</h3>
						<div style="width: 100% px">
							<!-- 网络蜘蛛列表开始 -->
							<%
								try {
										List spiders = (List) ((Operation) host
												.getObjectPool().get("Searcher")).getRobots();
										int size = spiders.size();
										for (int i = 0; i < size; i++) {
											pageContext.setAttribute("spider", spiders.get(i));
							%>
							<table width="100%">
								<tr>
									<td style="background-color: #99ccff">
										机器人名称
									</td>
									<td style="background-color: #eeeeee">
										${spider.name}
									</td>
								</tr>
								<tr>
									<td style="background-color: #99ccff">
										任务状态
									</td>
									<td style="background-color: #eeeeee">
										线程池大小：${spider.threadPoolSize}
										<br>
										等待任务：${spider.waitCount}
										<br>
										总任务数：${spider.waitCount+spider.runCount}
										<br>
										验证URL：${spider.alreadyURLCount}
										<br>
										有效URL：${spider.embodyURLCount}
										<br>
										收录统计：${spider.indexURLCount}
										<br>
									</td>
								</tr>
								<tr>
									<td style="background-color: #99ccff">
										业务统计
									</td>
									<td style="background-color: #eeeeee">
										查询统计：${spider.queryCount}
										<br>
										运行开始：${spider.runStartTime}
										<br>
										返回结果：${spider.returnResultCount}
										<br>
										查询耗时：${spider.queryTimeCount}
										<br>
									</td>
								</tr>
							</table>
							<%
								}
									} catch (Exception e) {
										e.printStackTrace();
									}
							%>
							<!-- 网络蜘蛛列表结束 -->
						</div>
						<h3 class="deep-bottom" style="width: 100% px">
							&nbsp;
						</h3>
					</div>

				</div>
				<script type="text/javascript">
	new AccControl("accordion_panel_${host.name}");
</script>
			</c:forEach>
			</div><br>
			页面执行时间：<%=new Date().getTime() - start.getTime()%>毫秒
		</center>
	</body>
</html>
